<template>
  <el-drawer
    :title="translate('policyDetail')"
    size="60%"
    :visible.sync="isShowDrawer"
  >
    <div class="detail_header">
      <div class="sp_bew">
        <div class="left">
          <div class="title_wrap">
            <div>
              <span class="title">{{ detail.marketingName }}</span>
              <span class="status">{{
                detail.marketingStatus == "1"
                  ? translate("yqy")
                  : translate("jy")
              }}</span>
            </div>
            <div class="placeholder9 mt10">
              {{
                detail.marketingType == "1"
                  ? translate("manzengPolicy")
                  : translate("manjianPolicy")
              }}
            </div>
          </div>
        </div>
      </div>
      <div class="createTime_wrap">
        <span
          class="item"
        >{{ translate("createTime") }}：{{ detail.createTime }}</span>
        <span
          class="item"
        >{{ translate("creator") }}：{{ detail.createUser }}</span>
        <div
          v-if="meta.indexOf('MarketingUseLogExport') > 1"
          class="download ml30"
          @click="UseLogDownload"
        >
          {{ translate("useRecordsDown") }}
        </div>
      </div>
    </div>
    <div class="separate" />
    <div class="property-title">{{ translate("policyppt") }}</div>
    <div class="line">
      <div class="key">{{ translate("policyName") }}：</div>
      <div class="value">{{ detail.marketingName }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("policyType") }}：</div>
      <div class="value">
        <span v-if="detail.marketingType == '1'">{{
          translate("manzengPolicy")
        }}</span>
        <span v-if="detail.marketingType == '0'">{{
          translate("manjianPolicy")
        }}</span>
        <span v-if="detail.marketingType == '2'">{{
          translate("disPolicy")
        }}</span>
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("policyRules") }}：</div>
      <div class="value">{{ detail.useDes }}</div>
    </div>
    <div v-if="detail.isDouble && detail.marketingType != '2'" class="line">
      <div class="key">{{ translate("bsdj") }}：</div>
      <div class="value">
        {{
          detail.isDouble == "1" ? translate("support") : translate("noSupport")
        }}
      </div>
    </div>
    <div v-if="detail.rank" class="line">
      <div class="key">{{ translate("priority") }}：</div>
      <div class="value">{{ detail.rank }}</div>
    </div>

    <div class="property-title">{{ translate("timeSet") }}</div>
    <div class="line">
      <div class="key">{{ translate("applyTime") }}：</div>
      <div class="value">
        {{ detail.useDateStart }} {{ translate("to") }} {{ detail.useDateEnd }}
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("timeSectionLimit") }}：</div>
      <div class="value">{{ detail.useTime }}</div>
    </div>

    <div class="property-title">{{ translate("applyRules") }}</div>
    <div class="line">
      <div class="key">{{ translate("orderType") }}：</div>
      <div class="value">{{ detail.orderTypeInfo }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("hydj") }}：</div>
      <div class="value">{{ detail.useCardLevelInfo }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("payMethod") }}：</div>
      <div class="value">{{ detail.payMethodInfo }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("applyVenue") }}：</div>
      <div class="value">{{ detail.stadiumInfo }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("applyProduct") }}：</div>
      <div class="value">{{ detail.useProject }}</div>
    </div>
  </el-drawer>
</template>

<script>
import {
  marketDetail,
  marketUseLogExport
} from '@/api'
export default {
  props: {
    meta: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      isShowDrawer: false,
      detail: {}
    }
  },
  methods: {
    getMarketDetail(id, row) {
      marketDetail({
        param: { id },
        userId: sessionStorage.getItem('userId')
      }).then(res => {
        if (res.errorCode !== '000000') return
        this.detail = { ...row, ...res.record }
      })
    },
    UseLogDownload() {
      const param = {
        id: this.detail.marketingId
      }
      marketUseLogExport({ param }).then(res => {
        if (res.errorCode !== '000000') return
        const elink = document.createElement('a')
        elink.style.display = 'none'
        elink.href = res.record.showUrl
        document.body.appendChild(elink)
        elink.click()
        document.body.removeChild(elink)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/styles/variables.scss";

.line {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  font-size: 14px;
  .key {
    color: #666666;
    // width: 90px;
    // text-align: right;
  }
  .value {
    color: #222222;
  }
}
.detail_header {
  font-size: 14px;
  .sp_bew {
    display: flex;
    justify-content: space-between;
    .left {
      display: flex;
      .img {
        width: 50px;
        height: 50px;
        margin-right: 20px;
      }
      .title {
        font-size: 18px;
        font-weight: 600;
        color: #222222;
      }
      .status {
        border-radius: 2px;
        border: 1px solid $primaryColor;
        color: $primaryColor;
        margin-left: 10px;
      }
    }
    .right {
      display: flex;
      background-color: #f4f7fc;
      border-radius: 2px;
      .item {
        padding: 14px 20px;
        .key {
          font-size: 12px;
          color: #666666;
        }
        .value {
          margin-top: 8px;
          color: #222222;
          font-weight: 600;
        }
      }
    }
  }
  .createTime_wrap {
    display: flex;
    align-items: center;
    margin: 16px 0;
    .item {
      margin-right: 30px;
      color: #999999;
    }
    .download {
      padding: 8px 16px;
      border: 1px solid #e0e2e7;
      border-radius: 2px;
      cursor: pointer;
    }
  }
}
.separate {
  height: 1px;
  margin: 20px -20px;
  padding: 0 20px;
  background-color: #dfe2e8;
}
.tip {
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}

.device-uploader {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  cursor: pointer;
  border: 1px dashed #ccc;
  border-radius: 8px;
  transition: all 0.3s;
  margin-right: 20px;

  &:hover {
    border-color: $menuActive;

    .uploader-icon {
      color: $menuActive;
    }
  }

  ::v-deep .el-upload {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;

    .file {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      background-size: contain;
      background-position: center;
      background-repeat: no-repeat;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;

      .delete {
        background-color: rgba(0, 0, 0, 0.5);
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        display: none;
        align-items: center;
        justify-content: center;

        .icon {
          color: #fff;
        }
      }

      &:hover {
        .delete {
          display: flex;
        }
      }
    }
  }

  .uploader-icon {
    color: #aaaaaa;
    font-size: 22px;
    transition: all 0.3s;
  }
}
.count-style {
  display: inline-block;
  width: 45%;
  height: 60px;
}

.division-line {
  text-align: center;
  display: inline-block;
  color: #999;
  width: 50px;
}

.clock {
  display: inline-block;
}

.upload-style {
  vertical-align: middle;
  display: inline-block;
  // width: 60px;
  // height: 60px;
  border: none;
}

.img-style {
  margin: auto;
  background-color: #eee;
  width: 100px;
  height: 60px;
  vertical-align: middle;
}

.avatar {
  width: 60px;
  height: 60px;
  display: block;
}

.line-style {
  background-color: #dfe2e8;
  height: 1px;
  // width: 80%;
  // margin: 0 auto;
  margin-bottom: 20px;
}
</style>
